package mya.mes.mdc.mqtt;

import com.fasterxml.jackson.databind.JsonNode;
import mya.common.model.json.JsonUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Administrator on 2020/12/2.
 */
public class Test {
    public static void main(String[] args) throws ParseException {
//        String val ="{\"DT\":\"2020-04-27 18:46:40\",\"0\":\"0\",\"1\":\"1\"}";
//        JsonNode jsonNode = JsonUtils.parse(val);
//        System.out.println(jsonNode.get("DT"));
//        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
////        Date date = new Date(1592377980975L);
//        Date date = sf.parse("2020-12-10 10:30");
//        String dateVal = sf.format(date.getTime()+30*60*1000);
//        System.out.println(dateVal);


        String startTime = "2020-12-10 10:00";
        String endTime = "2020-12-10 12:00";
        String interval = "30";
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            Date startDate = simpleDateFormat.parse(startTime);
            Date endDate = simpleDateFormat.parse(endTime);
            Long space = endDate.getTime() - startDate.getTime();
            Long count = space / (Integer.parseInt(interval) * 60 * 1000) + 1;
            String[] dateArray = new String[count.intValue()];
            int intervalTime = Integer.parseInt(interval);
            if(startDate.getTime() <= endDate.getTime()){
                int i = 0;
                for(Long start = startDate.getTime(); start <= endDate.getTime();start = (start + intervalTime * 60 * 1000 ),i ++){
                    dateArray[i] = simpleDateFormat.format(start);
                }
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println("123");
    }
}
